package com.pj.wisdomlogistics.mvp.presenter;


import com.pj.wisdomlogistics.entity.CarPoritionInfo;
import com.pj.wisdomlogistics.mvp.contract.CarPoritionContract;
import com.pj.wisdomlogistics.mvp.frame.ActivityPresenter;
import com.pj.wisdomlogistics.mvp.model.CarPoritionModel;
import com.pj.wisdomlogistics.rx.FilterSubscriber;


public class CarPoritionPresenter extends ActivityPresenter<CarPoritionModel, CarPoritionContract.View> implements CarPoritionContract.Presenter {

    @Override
    public void findCarAndDriver() {
        addSubscription(getModel().submitCarApply(), new FilterSubscriber<CarPoritionInfo>() {
            @Override
            public void onNext(CarPoritionInfo mInfo) {
                getView().onSuccess(mInfo);
            }

            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().onError(errorMsg);
            }


        });
    }


    @Override
    public void carApplyAllot(String userID, String carApplyID, String state, String driverName,
                              String driverTel, String carModel, String carNum, String driverID, String carID , String comment) {
        addSubscription(getModel().carApplyAllot(userID, carApplyID, state, driverName, driverTel, carModel, carNum, driverID, carID , comment), new FilterSubscriber() {
            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().onError(errorMsg);
            }

            @Override
            public void onNext(Object mO) {
                getView().onSendSuccess();
            }
        });
    }
}
